import urllib.request
headers = {'User-Agent':"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1"}
url='https://fgk.chinatax.gov.cn/zcfgk/c100009/listflfg_fg.html'
# response = urllib.request.urlopen(url=url,headers=headers)
# print(response.read().decode('utf-8'))

# response = urllib.request.urlopen('https://www.python.org')
# print(type(response))


# data = bytes(urllib.parse.urlencode({'name': 'germey'}), encoding='utf-8')
# response = urllib.request.urlopen('https://httpbin.org/post', data=data)
# print(response.read().decode('utf-8'))
from urllib.error import URLError
from urllib import request, error
 

request = urllib.request.Request(url=url,headers=headers,method='GET')
response = urllib.request.urlopen(request)
print(response.read().decode('utf-8'))

try:
    response = urllib.request.urlopen(url)
    html = response.read().decode('utf-8')
    print(html)
except error.HTTPError as e:
    print(e.reason, e.code, e.headers, sep='\n')
except error.URLError as e:
    print(e.reason)
else:
    print('Request Successfully')    